//*********基础功能重新封装**************//
function apiGet( url , data , func){
    log("进入apiGet,正在获取数据")
    logJson(data)
    $.ajax({
        url :  url,
        type : 'GET',
        data : data,
        headers: {
            // cookie: cookie()
        },
        success : function(data, status,requestCode,response, xhr) {
            // var cookie = getCookie(response)
            // if(typeof cookie == "string"){
            //     setLocData("cookie",cookie);
            // }
            try{
                var res = JSON.parse(data)
                logJson(res);
            }catch(e){
                showToast("数据异常");
                return;
            }finally{
            }
            apiDealWithResult(res,func)
        },
        error : function(e) {

        }
    });

}


function apiPost( url , data ,func){
    log("进入apiGet,正在获取数据")
    log(url)
    logJson(data)
    $.ajax({
        url :  url,
        type : 'POST',
        data : data,
        headers: {
            // cookie: cookie()
        },
        success : function(data, status,requestCode,response, xhr) {
            //log("Api Success Log")
            //log("response")
            //log(response)
            //log("data")
            //log(data)
            // var cookie = getCookie(response)
            // if(typeof cookie == "string"){
            //     setLocData("cookie",cookie);
            // }
            func(data)
        },
        error : function(e) {

        }
    });
}


function uploadOnePic (data ,func) {
    log("uploadOnePic")
    if (toOSS == 1 ) {
        uploadOnePicToOss(data,func)
    }else{
        var param = {Filedata:{path:data}}
        apiPost( "/MyWebPicUpload" , param ,func)
    }


}

function getCookie(response){
    // response = JSON.parse(response);
    // var headers = response.responseHeaders
    // var cookies = [];
    // for (var i in headers) {
    //     if (i == "Set-Cookie") {
    //         var arr = headers[i].split(";")
    //         cookies = arr[0];
    //     }
    // }
    // log("这是获取到的cookie");
    // logJson(cookies);
    // return cookies;
}

function cookie(){
    // var cookie = getLocData("cookie");
    // return cookie;
}




function apiDealWithResult(res,callback) {
    log("数据获取成功");
    log(res);

}

